import { getUserInfo } from "@/api/user";
import { userInfoStore } from "@/stores/userInfo";
import { type Token } from "@/interFace/user";
import { useRouter } from "vue-router";
export const userInfo =async (token:Token)=>{
  // 存token
  console.log('tokenHooks',token);
  
     userInfoStore().setLogin(token)

    //请求用户个人信息  token在 requery  axios的拦截器中已经附带了
    let res  =  await getUserInfo()
    // console.log(res);
  userInfoStore().setInfo(res.data)
  // console.log('hooksuserinfo');
  
  // useRouter().replace({ name:'Home'})

}

export const userInfoAgain = (token: Token)=>{
  userInfo(token)
}